﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Ccit.OA.MsNotify;
using Newtonsoft.Json;
using System.Collections.Generic;
using Ccit.OA.Utils;
namespace Ccit.OA.Notify
{
    public partial class notify_class_edit : Ccit.Utils.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                _hidsRecId.Value = (Request.QueryString["NotiID"] != null) ? Request.QueryString["NotiID"].ToString() : "";
                if (_hidsRecId.Value != "")
                {
                    InitPage();                     
                }                
            }
        }

        private void InitPage()
        {
            NotifyBLL Bll = new NotifyBLL();
            MsNotifyClass ms = Bll.GetNotiFyMes(_hidsRecId.Value);
            if(ms!=null)
            {
                 txtName.Text = ms.name;
                _hidRange.Value = ms.range;
                _hidRangeMarkId.Value = ms.rangemark;
                 txtRanage.Text = SysInterface.GetNameStrByIdStr(ms.range, ms.rangemark, ",");
                 radioType.SelectedValue = ms.state;
                freText.Text = (ms.temcontent!="")?ms.temcontent:"";
            }
        }
        #region Ajax Methods
        [global::System.Web.Services.WebMethod]
        public static string DoSaveMes(string strJson)
        {
            NotifyBLL Bll = new NotifyBLL();
            MsNotifyClass ms = (MsNotifyClass)JavaScriptConvert.DeserializeObject(strJson, typeof(MsNotifyClass));
            List<string> lstResult = Bll.DoSaveNotiFy(ms);
            var newObj = new { result = lstResult[0], message = lstResult[2], Notifyame = lstResult[1], ctrtype = "1" };
            string serExpr = JavaScriptConvert.SerializeObject(newObj);
            Bll = null;
            newObj = null;
            return serExpr;
        }
        #endregion
        #region Ajax Methods
        [global::System.Web.Services.WebMethod]
        public static string DoOperate(string sId)
        {
            NotifyBLL Bll = new NotifyBLL();
            List<string> lstResult = Bll.DoOperateNotiFy(sId);
            var newObj = new { result = lstResult[0], message = lstResult[1], ctrtype = "2" };
            string serExpr = JavaScriptConvert.SerializeObject(newObj);
            Bll = null;
            newObj = null;
            return serExpr;
        }
        #endregion
    }
}
